package na.edu.polytechnic;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class LocationInfo extends Activity {
   protected ArrayList<mOverlayItem> locations;
   protected mOverlayItem item;
   
   @Override
   public void onCreate(final Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Bundle b = getIntent().getExtras();
      item = b.getParcelable("item");
      setContentView(createView());
   }

   @Override
   public boolean onKeyDown(final int keyCode, final KeyEvent msg) {
      if (keyCode == KeyEvent.KEYCODE_BACK) {
         finish();
      }
      return true;
   }
   
   @Override
   public boolean onKeyUp(final int keyCode, final KeyEvent msg) {
      return true;
   }

   public View createView() {
      View v = getLayoutInflater().inflate(R.layout.location_info, null);
      
      ImageView image = (ImageView)v.findViewById(R.id.location_image);
      image.setImageResource(getResources().getIdentifier("drawable/"+item.picture, null, getPackageName()));
      
      TextView name = (TextView)v.findViewById(R.id.name_text);
      name.setText(item.getTitle());
      
      TextView address = (TextView)v.findViewById(R.id.address_text);
      address.setText(item.address);
      
      TextView infotext = (TextView)v.findViewById(R.id.info_text);
      infotext.setText(item.getSnippet());
      
      return v;
   }
}